package kr.hkit.androidcomplete02.ch17;

import java.io.File;

import kr.hkit.androidcomplete02.R;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;

public class CallOther extends Activity {
	
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch17_callother);
	}
	
	public void mOnClick(View v){
		Intent intent = null;
		switch(v.getId()){
		case R.id.ch17_web:
			intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://m.naver.com"));
			break;
		case R.id.ch17_dial:
			intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:010-1234-1234"));
			break;
		case R.id.ch17_picture:
			intent = new Intent(Intent.ACTION_VIEW);
			String sd = Environment.getExternalStorageDirectory().getAbsolutePath();
		//	Log.d("외부메모리 경로", sd);
			Uri uri = Uri.fromFile(new File(sd+"/Download/andExam.png"));
//			Uri uri = Uri.fromFile(new File(sd+"/airplane.png"));
			intent.setDataAndType(uri, "image/png");
			break;
		case R.id.ch17_other:
/*			intent = new Intent(Intent.ACTION_MAIN);
			intent = new Intent();
			intent.setComponent(new ComponentName("kr.hkit.androidcomplete01.ch11", "kr.hkit.androidcomplete01.MainActivity"));
			intent.setClassName("kr.hkit.androidcomplete01", "kr.hkit.androidcomplete01.MainActivity");*/
			intent = new Intent("kr.hkit.androidcomplete02.ch17.ADD");
			intent.putExtra("left", 6);
			intent.putExtra("right", 7);
			break;
		}
		startActivity(intent);
	}
}
